package org.example.controller;

import com.github.pagehelper.PageInfo;
import org.example.entity.Psych;
import org.example.entity.PsychReply;
import org.example.service.PsychReplyService;
import org.example.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName PsychReplyController
 * @Description TODO
 * @Author lipeijin
 * @Date 2025年08月16日 下午7:19
 * @Version 1.0
 */
@RestController
@RequestMapping("PsychReply")
public class PsychReplyController {
    @Autowired
    private PsychReplyService psychReplyService;
    @GetMapping("{id}")
    public R getPage(@PathVariable("id") int id,
                     @RequestParam(required = false,defaultValue = "1") int pageNum,
                     @RequestParam(required = false,defaultValue = "10") int PageSize){
        PageInfo<PsychReply> pageInfo = psychReplyService.getPage(id,pageNum, PageSize);
        return R.ok(pageInfo);
    }
    @PostMapping("add")
    public R addPsychr(@RequestBody PsychReply psychReply){
        int i = psychReplyService.addPsychReply(psychReply);
        if(i>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }

}
